﻿using ProjectFootball.MVC.Models.EntityFramework.Entities;
using System;
using System.Security.Principal;

namespace ProjectFootball.MVC.Areas.VenueArea.Models
{
    public static class _VenueDataModelExtensions
    {
        public static Venue CreateNew(this VenueDataModel venueDataModel, IPrincipal user)
        {
            venueDataModel.ApprovalGuid = Guid.NewGuid();
            return venueDataModel.CreateLinked(user);
        }

        public static Venue CreateLinked(this VenueDataModel venueDataModel, IPrincipal user)
        {
            return new Venue()
            {
                Pk = Guid.NewGuid(),
                ApprovalGuid = venueDataModel.ApprovalGuid,
                VenueName = venueDataModel.VenueName,
                Address = venueDataModel.Address,
                CountryGuid = (Guid)venueDataModel.CountryGuid,
                Capacity = venueDataModel.Capacity,
                IsApproved = user.IsApprover(),
                AuditUserId = user.GetUserId(),
                AuditTimestamp = DateTime.Now
            };
        }
    }
}